import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Storage } from '@ionic/storage';

/*
  Generated class for the Settings page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Component({
  selector: 'page-settings',
  templateUrl: 'settings.html'
})
export class SettingsPage {

  _storyNotify: boolean = false;

  get storyNotify(): boolean
  {
    return this._storyNotify;
  }
  set storyNotify(v)
  {
    this._storyNotify = v;
    this.storage.set('story_notify', v);
  }

  _mbNotify: boolean = false;

  get mbNotify(): boolean
  {
    return this._mbNotify;
  }
  set mbNotify(v)
  {
    this._mbNotify = v;
    this.storage.set('mb_notify', v);
  }

  _photoNotify: boolean = false;

  get photoNotify(): boolean
  {
    return this._photoNotify;
  }
  set photoNotify(v)
  {
    this._photoNotify = v;
    this.storage.set('photo_notify', v);
  }

  constructor(
    public navCtrl: NavController,
    private storage: Storage
  ) {
    storage.get('story_notify').then(v => {
      if (v == null)
      {
        storage.set('story_notify', false);
        this._storyNotify = false;
      }
      else {
        this._storyNotify = v;
      }
      this._storyNotify = v;
    });
    storage.get('mb_notify').then(v => {
      if (v == null)
      {
        storage.set('mb_notify', false);
        this._mbNotify = false;
      }
      else {
        this._mbNotify = v;
      }
    });
    storage.get('photo_notify').then(v => {
      if (v == null)
      {
        storage.set('photo_notify', false);
        this._photoNotify = false;
      }
      else {
        this._photoNotify = v;
      }
    });

  }

  ionViewDidLoad() {

  }

}
